﻿using System; 
using System.Data;
using System.Collections.Generic; 
using JOIN.Rights.Model;

/*------------------------------------------------------------------------
   苏州捷安信息科技有限公司 版权所有			
   文件名: TU_Menus.cs
   作 者 : 席吉波
   日 期 : 2012/10/12 16:10:43
   备 注 : 当您对本文件更改时请写明修改人、修改日期以及是由
  ------------------------------------------------------------------------
*/

namespace JOIN.Rights.BLL
{
	 	//TU_Menus
		public partial class MenusBLL:BLLBase
	{
		//private readonly ITU_Menus dal=DataAccess.CreateTU_Menus();
		public MenusBLL(MenusInfo entity)
			:base(entity)
		{
		
		}
		
		#region  Method
		/*
		/// <summary>
		/// 是否存在该记录
		/// </summary>
		public bool Exists()
		{
			return dal.Exists();
		}

		/// <summary>
		/// 增加一条数据
		/// </summary>
		public void  Add(JOIN.Rights.Model.TU_Menus model)
		{
			dal.Add(model);
						
		}

		/// <summary>
		/// 更新一条数据
		/// </summary>
		public bool Update(JOIN.Rights.Model.TU_Menus model)
		{
			return dal.Update(model);
		}

		/// <summary>
		/// 删除一条数据
		/// </summary>
		public bool Delete()
		{
			
			return dal.Delete();
		}
		
		/// <summary>
		/// 得到一个对象实体
		/// </summary>
		public JOIN.Rights.Model.TU_Menus GetModel()
		{
			
			return dal.GetModel();
		}

		/// <summary>
		/// 得到一个对象实体，从缓存中
		/// </summary>
		public JOIN.Rights.Model.TU_Menus GetModelByCache()
		{
			
			string CacheKey = "TU_MenusModel-" + ;
			object objModel = Maticsoft.Common.DataCache.GetCache(CacheKey);
			if (objModel == null)
			{
				try
				{
					objModel = dal.GetModel();
					if (objModel != null)
					{
						int ModelCache = Maticsoft.Common.ConfigHelper.GetConfigInt("ModelCache");
						Maticsoft.Common.DataCache.SetCache(CacheKey, objModel, DateTime.Now.AddMinutes(ModelCache), TimeSpan.Zero);
					}
				}
				catch{}
			}
			return (JOIN.Rights.Model.TU_Menus)objModel;
		}

		/// <summary>
		/// 获得数据列表
		/// </summary>
		public DataSet GetList(string strWhere)
		{
			return dal.GetList(strWhere);
		}
		/// <summary>
		/// 获得前几行数据
		/// </summary>
		public DataSet GetList(int Top,string strWhere,string filedOrder)
		{
			return dal.GetList(Top,strWhere,filedOrder);
		}
		/// <summary>
		/// 获得数据列表
		/// </summary>
		public List<JOIN.Rights.Model.TU_Menus> GetModelList(string strWhere)
		{
			DataSet ds = dal.GetList(strWhere);
			return DataTableToList(ds.Tables[0]);
		}
		/// <summary>
		/// 获得数据列表
		/// </summary>
		public List<JOIN.Rights.Model.TU_Menus> DataTableToList(DataTable dt)
		{
			List<JOIN.Rights.Model.TU_Menus> modelList = new List<JOIN.Rights.Model.TU_Menus>();
			int rowsCount = dt.Rows.Count;
			if (rowsCount > 0)
			{
				JOIN.Rights.Model.TU_Menus model;
				for (int n = 0; n < rowsCount; n++)
				{
					model = new JOIN.Rights.Model.TU_Menus();					
													model.ProjectID= dt.Rows[n]["ProjectID"].ToString();
																												model.MenuID= dt.Rows[n]["MenuID"].ToString();
																												model.MenuName= dt.Rows[n]["MenuName"].ToString();
																												model.MenuDesc= dt.Rows[n]["MenuDesc"].ToString();
																												model.MenuLink= dt.Rows[n]["MenuLink"].ToString();
																								if(dt.Rows[n]["MenuLevel"].ToString()!="")
				{
					model.MenuLevel=int.Parse(dt.Rows[n]["MenuLevel"].ToString());
				}
																												model.MenuParent= dt.Rows[n]["MenuParent"].ToString();
																												model.MenuIcoUrl= dt.Rows[n]["MenuIcoUrl"].ToString();
																												model.MenuCssName= dt.Rows[n]["MenuCssName"].ToString();
																												model.FunctionID= dt.Rows[n]["FunctionID"].ToString();
																								if(dt.Rows[n]["OrderIndex"].ToString()!="")
				{
					model.OrderIndex=int.Parse(dt.Rows[n]["OrderIndex"].ToString());
				}
																						
				
					modelList.Add(model);
				}
			}
			return modelList;
		}

		/// <summary>
		/// 获得数据列表
		/// </summary>
		public DataSet GetAllList()
		{
			return GetList("");
		}
		//*/
#endregion
   
	}
}